<?php
abstract class Pageley_Domain_Attribute_MultipleDecorator extends Pageley_Domain_Attribute_Decorator {
    
	public function __construct($attribute) {
		$validators = new Pageley_Util_ArrayMap();
        parent::__construct($attribute, $validators);
	}
	
	public function getName() {
		return $this->name;
	}
	
	public function validate($values, $propertyName, $target) {
		$errors = new Pageley_Util_ArrayMap();
		if($values !== null) {
			foreach($values as $value) {
				$error = $this->getDecoratedAttribute()->validate($value, $propertyName, $target);
				if($error != null) {
					$errors->putAll($error);
				}
			}
		}
		if($errors->size() > 0) {
			throw new Pageley_Domain_Validator_Exception($errors);
		}
	}
	
	public function isMultiple() {
		return true;
	}
    
    public abstract function isManyToMany();
	
	public function isReference() {
		return false;
	}
    
    public function isComposite() {
    	return false;
    }
    
    public function shouldEncrypt() {
    	return false;
    }
	
	public function newProperty() {
		return new Pageley_Domain_ValueListProperty();
	}
}